package xiangmu.schoolpaper.controller.bingo.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import xiangmu.schoolpaper.pojo.VO.SystemNameAndAccount;
import xiangmu.schoolpaper.pojo.VO.SystemSplitStudentInfo;
import xiangmu.schoolpaper.result.Result;
import xiangmu.schoolpaper.service.AdminDataListService;

import java.util.List;

@RestController
@RequestMapping("/system/paper/metadata")
@Slf4j
@Tag(name = "管理员端——4数据管理——2论文元数据管理")
public class SystemPaperMetadataManagementController {
    @Autowired
    private AdminDataListService adminDataListService;

    /*
        先决条件
     */
    @GetMapping("/graduation-year")
    @Operation(summary = "1先决条件——获取所有毕业年份（本学院）")
    public Result<List<Integer>> graduationYear(Integer facultyId){
        log.info("返回毕业年份");
        List<Integer> graduationYear = adminDataListService.graduationYear(facultyId);
        return Result.success(graduationYear);
    }

    @GetMapping("/student-info")
    @Operation(summary = "2先决条件——获取所有学生姓名和学号（本学院）")
    public Result<List<SystemNameAndAccount>> nameAndId(Integer facultyId){
        log.info("返回学生姓名和学号");
        List<SystemNameAndAccount> systemNameAndAccount = adminDataListService.nameAndId(facultyId);
        return Result.success(systemNameAndAccount);
    }

    /*
        论文元数据管理
    */
    @GetMapping("/get-all-student-paper")
    @Operation(summary = "3论文元数据管理——获取所有符合筛选条件的论文元数据")
    public Result<IPage<SystemSplitStudentInfo>> getAllStudentPaper(
            @RequestParam(defaultValue = "1") Integer currentPage,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) Integer facultyId,
            @RequestParam(required = false) Integer graduationYear,
            @RequestParam(required = false) String studentAccount,
            @RequestParam(required = false) String paperTitle
    ) {
        log.info("返回所有符合筛选条件的论文元数据");
        IPage<SystemSplitStudentInfo> pageData = adminDataListService.getAllStudentPaper(currentPage, pageSize, facultyId, graduationYear, studentAccount, paperTitle);
        return Result.success(pageData);
    }
}
